package com.yeung.annotation.entity;

import org.springframework.stereotype.Component;

@Component
public class Person {
    public String name;
    public int age;

    /*加了compoent注解,必须要有无参构造方法
        因为spring默认调用无参构造方法创建实例之后,再使用属性注入值*/
    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
